//
//  MineControl.m
//  FreeTime
//
//  Created by  on 16/8/25.
//  Copyright © 2016年 SRDZ.com. All rights reserved.
//

#import "MineControl.h"
#import "PersonDetailControl.h"
#import "HeartControl.h"
#import "AccountControl.h"
#import "SexControl.h"
#import "MineCell.h"
#import "Header.h"
#import "EditPersonControl.h"
#import "SettingControl.h"
#import "QuoteControl.h"
#import "TAZUWOControl.h"
#import "WOZUTAControl.h"
@interface MineControl (){
    NSArray * dataArr;
    NSArray * imgArr;
    NSArray * vcArray;
}

@end

@implementation MineControl

- (void)viewWillAppear:(BOOL)animated{
    
    self.navigationController.navigationBarHidden = YES;

    self.navigationController.interactivePopGestureRecognizer.enabled = NO;

}
- (void)viewWillDisappear:(BOOL)animated{
    self.navigationController.navigationBarHidden = NO;
//    self.navigationController.interactivePopGestureRecognizer.enabled = NO;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self loadOrigData];
    [self setupUI];
    [self creatVC];

}
#pragma mark -- selfStyle -- 
-(void)setupUI{
//    self.view.backgroundColor = HOME_COLOR;
    UIView * headerView = [[UIView alloc] init];
    headerView.backgroundColor = [UIColor whiteColor];
    headerView.userInteractionEnabled = YES;
    UIImageView * bgImg = [ReduceCode creatImageVeiwWithFrame:CGRectMake(0, 0, WindowWidth, WindowWidth*0.32) imageName:@"MineBGImg" isCorner:NO];
    bgImg.userInteractionEnabled = YES;
    [headerView addSubview:bgImg];
    
    UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(editPerson)];
    UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake((WindowWidth-80)/2, CGRectGetMaxY(bgImg.frame)-40, 80, 80);
    btn.layer.cornerRadius = 40;
    [btn addTarget:self action:@selector(pushPerson) forControlEvents:UIControlEventTouchUpInside];
    btn.layer.masksToBounds = YES;
    [btn setBackgroundImage:[UIImage imageNamed:@"123"] forState:UIControlStateNormal];
//    UIImageView * iconImg = [ReduceCode creatImageVeiwWithFrame:CGRectMake((WindowWidth-72)/2, CGRectGetMaxY(bgImg.frame)-36, 72, 72) imageName:@"123" isCorner:YES];
    
//    iconImg.userInteractionEnabled = YES;
//    
//    [iconImg addGestureRecognizer:tap];
    [headerView addSubview:btn];
    
    UILabel * nameLbl = [ReduceCode creatLabelWithFrame:CGRectMake(0, CGRectGetMaxY(btn.frame)+5, WindowWidth, 20) title:@"德玛西亚" titleColor:[ImageUtil colorWithRgb:0x666666] font:15 textAlignment:1];
    [headerView addSubview:nameLbl];
    
    UILabel * contentLbl = [ReduceCode creatLabelWithFrame:CGRectMake(0, CGRectGetMaxY(nameLbl.frame), WindowWidth, 25) title:@"编辑资料   ID:10001" titleColor:[ImageUtil colorWithRgb:0x999999] font:14 textAlignment:1];
    contentLbl.userInteractionEnabled = YES;
    [contentLbl addGestureRecognizer:tap];
//    [ToolUtil createVerticalLine:7 superView:contentLbl lift:WindowWidth/2 height:10 color:[ImageUtil colorWithRgb:0x666666]];
    [headerView addSubview:contentLbl];
    
    headerView.frame = CGRectMake(0, 0, WindowWidth, CGRectGetMaxY(contentLbl.frame)+15);
    self.tableView.tableHeaderView = headerView;
//    self.tableView.contentInset = UIEdgeInsetsMake(-200, 0, 0, 0);
//    self.tableView.backgroundColor = HOME_COLOR;
    [self.tableView registerClass:[MineCell class] forCellReuseIdentifier:@"MineCell"];
    self.tableView.bounces = YES;
    self.tableView.frame = CGRectMake(0, 0, WindowWidth, WindowHeight-49);
    
    
    
}
- (void)loadOrigData{
    dataArr = @[@"我租了TA",@"TA租了我",@"报价",@"出租自己",@"我的钱包",@"设置",@"联系我们"];
    imgArr = @[@"zuTA",@"TAzuwo",@"pushMoney",@"chushou",@"moneyPackge",@"shezhi",@"lianxi"];
    
}
- (void )creatVC{
    
    WOZUTAControl * zutaVC = [WOZUTAControl new];
    TAZUWOControl * zuwoVC = [TAZUWOControl new];
    QuoteControl * quoteVC = [QuoteControl new];

    AccountControl * accountVC = [AccountControl new];
    SexControl * sexVC = [SexControl new];
    SettingControl * setVC = [SettingControl new];
    vcArray = @[zutaVC,zuwoVC,quoteVC,accountVC,sexVC,setVC,sexVC];
    
}
#pragma mark tableViewMethord
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return dataArr.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 60;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString * cellIdentifier = @"MineCell";
    MineCell * cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.chooseImg.image = [UIImage imageNamed:imgArr[indexPath.row]];
    cell.titleLbl.text = dataArr[indexPath.row];
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    UIViewController * vc = vcArray[indexPath.row];
    vc.hidesBottomBarWhenPushed =YES;
    [self.navigationController pushViewController:vc animated:YES];
    //    SexCell * cell = [tableView cellForRowAtIndexPath:indexPath];
}

#pragma mark -- 响应事件 --
- (void)pushPerson{
    PersonDetailControl * personVC = [PersonDetailControl new];
    personVC.hidesBottomBarWhenPushed =YES;
    [self.navigationController pushViewController:personVC animated:YES];
    
}
- (void)editPerson{
    EditPersonControl *editVc=[[EditPersonControl alloc]init];
    editVc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:editVc animated:YES];

}


@end
